#include "SchmidtCAM.h"

int main( int argc, char *argv[] ){

    int fd = open("/dev/mem", O_RDWR | O_SYNC);
    uint *ptr1 = mmap(NULL, 10, PROT_READ | PROT_WRITE, MAP_SHARED, fd, ADDR_GPIO_OUT);
    uint *gpio_reg      = ptr1;     // 0x41200000

    if( argc == 1 ){
        sync_ad9508( gpio_reg );
    }

    if( argc == 2 ){
        int opt = atoi(argv[1]);
        
        if( opt == 0 ){
            printf("> (ad9508) pull-down SYNC.\n");
            setbit(*gpio_reg, BIT_SYNC_9508);
        } else if( opt == 1 ){
            printf("> (ad9508) pull-up SYNC.\n");
            clrbit(*gpio_reg, BIT_SYNC_9508);
        }
    }

    munmap(ptr1,10);
    close(fd);

    return 0;
}
